package 变长滑动窗口1

func maxConsecutiveAnswers(answerKey string, k int) (ans int) {
	left1 := 0
	left2 := 0
	cntt := 0
	cntf := 0
	for i, str := range answerKey {
		if str == 'T' {
			cntt++
		} else {
			cntf++
		}
		for cntt > k {
			if answerKey[left1] == 'T' {
				cntt--
			}
			left1++
		}
		for cntf > k {
			if answerKey[left2] == 'F' {
				cntf--
			}
			left2++
		}
		ans = max(ans, i-left1+1)
		ans = max(ans, i-left2+1)

	}
	return
}
